/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utilities;

import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Rafael Bisk8
 */
public class Calendario extends Calendar {

    protected void computeFields() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    protected void computeTime() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    /**
     * 
     * @param data java.util.Date
     * @return Data formatada como "dd/mm/aaaa"
     */
    public static String retornaDataDDMMAAAA(Date data) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(data);      
        StringBuffer sb = new StringBuffer();
        if (cal.get(Calendar.DATE)<10) {
            sb.append(0).append(cal.get(Calendar.DATE)).append("/");
        }else{
            sb.append(cal.get(Calendar.DATE)).append("/");
        }
        
        if ((cal.get(Calendar.MONTH)+1)<10) {
            sb.append(0).append(cal.get(Calendar.MONTH)+1);
        } else {
            sb.append(cal.get(Calendar.MONTH)+1);
        }            
        return sb.append("/").append(cal.get(Calendar.YEAR)).toString();
    }
}
